import RestClient from "@/driver/RestClient"

const CoupletService = {
    /**
     * 获取今日对联.
     * @param day
     * @param callback
     * @param failCallback
     */
    getToday (day, callback, failCallback) {
        RestClient.get(`/api/v1/couplets/days/${day}`, callback, failCallback)
    },
    /**
     * 添加下联.
     * @param data
     * @param callback
     * @param failCallback
     */
    replyCouplet (data, callback, failCallback) {
        return RestClient.post('/api/v1/couplets/actions/reply', data, callback, failCallback)
    },

    /**
     * 获取下联列表.
     * @param coupletId
     * @param page
     * @param callback
     * @param failCallback
     */
    getReplyList(coupletId, page, callback, failCallback) {
        RestClient.get('/api/v1/couplets/{0}/replies?page={1}'.formats(coupletId, page), callback, failCallback)
    },

    /**
     * 删除下联.
     * @param coupletId
     * @param id
     * @param callback
     * @param failCallback
     */
    delReply(coupletId, id, callback, failCallback) {
        RestClient.delete(`/api/v1/couplets/${coupletId}/replies/${id}`, callback, failCallback)
    },

    /**
     * 修改下联.
     * @param coupletId
     * @param id
     * @param data
     * @param callback
     * @param failCallback
     */
    modifyReply(coupletId, id, data, callback, failCallback) {
        RestClient.put(`/api/v1/couplets/${coupletId}/replies/${id}`, data, callback, failCallback)
    }
}

export default CoupletService